package com.epower.bo.epowerbook.impl;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.epower.base.BaseBO;
import com.epower.bo.epowerbook.EpowerBookService;
import com.epower.dao.epowerbook.EpowerBookDAO;
import com.epower.dataobject.EpowerBookDO;

/***
 * BO层实现类
 * 
 * @author QuickDev
 * 
 */
@Scope("singleton")
@Component("epowerBookBO")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class EpowerBookServiceImpl extends BaseBO implements EpowerBookService {
	private EpowerBookDAO epowerBookDAO;

	/***
     * 
     */
	@Override
	public EpowerBookDO getEpowerBookByOption(EpowerBookDO epowerBook) {
		return epowerBookDAO.getEpowerBookByOption(epowerBook);
	}

	/***
     * 
     */
	@Override
	public List<EpowerBookDO> getEpowerBookListByOption(EpowerBookDO epowerBook) {
		return epowerBookDAO.getEpowerBookListByOption(epowerBook);
	}

	@Override
	public List<EpowerBookDO> getEpowerBookListPageByOption(EpowerBookDO epowerBook) {
		int totalItem = getEpowerBookCountByOption(epowerBook);
		epowerBook.setTotalItem(totalItem);
		return epowerBookDAO.getEpowerBookListByOption(epowerBook);
	}

	/***
     * 
     */
	@Override
	public EpowerBookDO getEpowerBookById(Integer id) {
		return epowerBookDAO.getEpowerBookById(id);
	}

	/***
     * 
     */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public boolean deleteEpowerBookById(Integer id) {
		return epowerBookDAO.deleteEpowerBookById(id);
	}

	/***
     * 
     */
	@Override
	public Integer getEpowerBookCountByOption(EpowerBookDO epowerBook) {
		return epowerBookDAO.getEpowerBookCountByOption(epowerBook);
	}

	/***
     * 
     */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public boolean updateEpowerBookByOption(EpowerBookDO epowerBook) {
		return epowerBookDAO.updateEpowerBookByOption(epowerBook);
	}

	/***
     * 
     */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public Integer addEpowerBook(EpowerBookDO epowerBook) {
		try {
			Integer id = epowerBookDAO.addEpowerBook(epowerBook);
			return id;
		} catch (Exception e) {
			throw new RuntimeException("service is error");
		}
	}

	/***
	 * 
	 * @getter setter
	 */
	public EpowerBookDAO getEpowerBookDAO() {
		return epowerBookDAO;
	}

	@Resource
	public void setEpowerBookDAO(EpowerBookDAO epowerBookDAO) {
		this.epowerBookDAO = epowerBookDAO;
	}

	@Override
	public List<EpowerBookDO> getEpowerBookIdsByOption(EpowerBookDO epowerBook) {
		return epowerBookDAO.getEpowerBookIdsByOption(epowerBook);
	}


	@Override
	public boolean isBook(Integer id) {
		 
		return epowerBookDAO.isBook(id);
	}


	@Override
    public List<EpowerBookDO> getEpowerBookListByName(EpowerBookDO epowerBook) {
        return epowerBookDAO.getEpowerBookListByName(epowerBook);
    }

    @Override
    public List<EpowerBookDO> getEpowerBookListByPid(int pid) {
        return epowerBookDAO.getEpowerBookListByPid(pid);
    }

}
